﻿using System;
using System.Collections.Generic;
using System.Linq;
using hellaSharp;
using System.Text;

namespace hellaBot
{
    class Terminal
    {
        public static Jabber xmpp;
        private static HellaSharp myhella = new HellaSharp(Program.configuration.hellanzbxmlurl, Program.configuration.hellanzbpass);

        public Terminal()
        {
        }

        static public void PrintMessage(string input)
        {
            Console.WriteLine(input);
        }
        static public void PrintError(string input)
        {
            Console.WriteLine("ERROR: " + input);
        }

        static public void ReadInput()
        {
            while (true)
            {
                string input = Console.ReadLine();

                if (input == "quit")
                {
                    Program.Die();
                    return;
                }

                string[] parts;
                char[] splitter = { ' ' };
                parts = input.Split(splitter, 3);
                if (parts.Length == 0)
                    continue;

                switch (parts[0])
                {
                    case "join":
                        xmpp.JoinMuc(parts[1]);
                        break;
                    case "say":
                        xmpp.Say(parts[1], parts[2]);
                        break;
                    case "newzbin":
                        if (parts.Length != 2)
                            Terminal.PrintError("Syntax invalid try newzbin <id>");
                        else
                        {
                            myhella.EnqueueId(parts[1]);
                        }
                        break;
                }
            }
        }
    }
}
